#include <csignal>
#include <vsomeip/vsomeip.hpp>
#include "someip_client.hpp"

hello_world_client * client_ptr = nullptr;

void handle_signal(int _signal) {
    if (client_ptr != nullptr &&
    (_signal == SIGINT || _signal == SIGTERM)) 
    {
        LOG_INF("signal:%d", _signal);
        client_ptr->stop();
    }
}

int main(int argc, char * argv) {
    (void)argc;
    (void)argv;

    LOG_INF("some ip client running");

    hello_world_client hw_cl;
    client_ptr = &hw_cl;
    signal(SIGINT, handle_signal);
    signal(SIGTERM, handle_signal);

    if (hw_cl.init()) {
        hw_cl.start();
        return 0;
    }
    else {
        return 0;
    }
}